import { Entity, PrimaryUuid, Unique, UpdateDate, CreateDate, DateTime, SysUserId, Ip, TokenStatus, Token } from '@sker/core'
@Entity({ name: 'sys_token' })
@Unique('UK_REFRESH_TOKEN', ['refresh_token'])
@Unique('UK_TOKEN', ['token'])
export class SysToken {
    static title: string = `登录凭证`;
    static resource: string = `sys_token`;

    @PrimaryUuid({
        primaryKeyConstraintName: 'PK_SYS_TOKEN_ID'
    })
    id!: string;

    @SysUserId({ comment: '用户id' })
    uid!: string;

    @Ip({ comment: 'ip地址' })
    ip!: string;

    @TokenStatus({ comment: '状态' })
    status!: number;

    @Token({
        comment: '登录凭证'
    })
    token!: string;

    @Token({
        comment: 'hasura凭证',
        nullable: true
    })
    hasura!: string;

    @Token({
        comment: '刷新凭证'
    })
    refresh_token!: string;

    @DateTime({ comment: '登录凭证过期时间' })
    expires_in!: Date;

    @DateTime({ comment: '刷新凭证过期时间' })
    refresh_token_expires_in!: Date;

    @CreateDate({ comment: '登录时间' })
    login_date!: Date;

    @UpdateDate({ comment: '更新时间' })
    update_date!: Date;
}